package com.evasion.util;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import com.evasion.controladores.EmpresaDataManager;

@ManagedBean 
@RequestScoped
@FacesConverter("evasionConverter")
public class EvasionConverter implements Converter{
	
	@ManagedProperty(value="#{empresaDataManager}")
	private EmpresaDataManager ds;
	
	public EmpresaDataManager getDs() {
		return ds;
	}

	public void setDs(EmpresaDataManager ds) {
		this.ds = ds;
	}

	@Override
	public Object getAsObject(FacesContext context, UIComponent component,String value) {
		if(component.getId().equalsIgnoreCase("advanced"))
		{
		  Evasion p=new Evasion();
			p.setId(value);
				return p;
		
		}
		return null;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component,Object value) {
		if(value instanceof Evasion){
			Evasion evasion = (Evasion)value;
			return evasion.getId();
		}
		return "";
	}

}
